#ifndef OPERATEFILE_H
#define OPERATEFILE_H

#include <QString>
#include "sftpclient.h"
#include "tinyxml2.h"
#include <QDir>
#include <QStringList>
#include <QDateTime>
#include <QTimer>
using namespace tinyxml2;

class OperateFile
        : public sftpClient
{

public:
    OperateFile();

    ~OperateFile();

    /**
     * @brief ScanFile
     *  scan for fsn files
     */
    void ScanFile();

    /**
     * @brief ReadFromXml
     *  read sftp config
     */
    const int ReadFromXml();

    /**
     * @brief SftpOpen
     *  connect to sftp server
     */

    const int SftpOpen();

    /**
     * @brief RemoveAndBackupFile
     * @param slocalfile
     *  remove and backup fsn after upload
     */
    const int RemoveAndBackupFile(QString slocalfile);

    void CheckPath();

    const char *ReadXmlValue(tinyxml2::XMLElement *root, const char *element);

    void LoadConfFromW(QString host_ip_, QString port_, QString user_name_, QString pass_word_, QString file_path_, QString file_path_backup_, QString sftp_path_, QString user_auth, QString public_file_path, QString private_file_path, QString pass_phrase, QString circle_time);

    const int GetCircleTime();

    void SaveXmlOneByOne(tinyxml2::XMLDocument *doc, tinyxml2::XMLElement *root, const char *element, QString s);

    int SaveAsSftpConf();


private :
    QString xml_path_;

public :

    QString getIp();

    QString getPort();

    QString getUserName();

    QString getPassWord();

    QString getSftpPath();

    QString getFilePath();

    QString getFilePathBackup();

    QString getUserAuth();

    QString getPublicFilePath();

    QString getPrivateFilePath();

    QString getPassPhrase();

    QString getCircleTimeS();
};

#endif // OPERATEFILE_H
